<style lang="less">
    .early-warning-notic {
        margin-right: 10px;
    }
</style>
<template>
    <div :class="wrpCls">
        <span
            :class="prefixCls"
            class="early-warning-notic"
            @click="toIndexEarlyWarning"
            v-if="showIndexEarlyWarningCount"
        >
            <a-badge
                :count="indexEarlyWarningCount"
                :offset="[10,0]"
            >指标预警</a-badge>
        </span>
        <avatar-dropdown
            :menu="showMenu"
            :current-user="currentUser"
            :class="prefixCls"
            @onSettingClick="onSettingClick"
        />
        <PasswordEditVue ref="PasswordEditVue"></PasswordEditVue>
    </div>
</template>

<script>
    import AvatarDropdown from './AvatarDropdown'
    // import SelectLang from '@/components/SelectLang'
    import PasswordEditVue from '@/modules/common/components/PasswordEdit.vue'
    import { getNowUserInfo } from '@/modules/common/service/base.js'
    import { PasswordEditTypeEnum } from '@/modules/common/enum/enum'

    export default {
        name: 'RightContent',
        components: {
            AvatarDropdown,
            PasswordEditVue
            // SelectLang
        },
        props: {
            prefixCls: {
                type: String,
                default: 'ant-pro-global-header-index-action'
            },
            isMobile: {
                type: Boolean,
                default: () => false
            },
            topMenu: {
                type: Boolean,
                required: true
            },
            theme: {
                type: String,
                required: true
            }
        },
        data() {
            return {
                showMenu: true,
                // currentUser: {
                //     name: getNowUserInfo().userName
                // }
            }
        },
        computed: {
            wrpCls() {
                return {
                    'ant-pro-global-header-index-right': true,
                    [`ant-pro-global-header-index-${(this.isMobile || !this.topMenu) ? 'light' : this.theme}`]: true
                }
            },
            indexEarlyWarningCount() {
                return this.$store.state.indexEarlyWarningCount;
            },
            showIndexEarlyWarningCount() {
                const nowUserInfo = getNowUserInfo();
                const sysCustomer = nowUserInfo&&nowUserInfo.sysCustomer;
                // 就诊人指标预警,客服则展示
                return sysCustomer && sysCustomer.customerType && sysCustomer.customerType.includes(1) ? true : false;
            },
            currentUser(){
                const userInfo = getNowUserInfo() || {};
                return {
                    name: userInfo.nickName
                }
            }
        },
        mounted() {
            // this.$store.dispatch('refreshIndexEarlyWarningCount')
        },
        methods: {
            onSettingClick() {
                const { id } = getNowUserInfo();
                const type = PasswordEditTypeEnum.USER_PASSWORD;
                this.$refs.PasswordEditVue.show({ id, type });
            },
            toIndexEarlyWarning() {
                this.$router.push('/indexEarlyWarning');
            }
        }
    }
</script>
